import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

/**
 * @author gao
 * @date 2025/8/20 23:04
 */

public class Solution {
    public int[] twoSum(int[] nums, int target) {
        Map<Integer, Integer> hash = new HashMap<>();
        for (int i = 0; i < nums.length; i++) {
            int x = target - nums[i];
            if (hash.containsKey(x)) {
                return new int[]{i, hash.get(x)};
            }
            hash.put(nums[i], i);
        }
        return new int[]{0, 0};
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNext()) {
            int n = in.nextInt();
            int[] nums = new int[n];
            for (int i = 0; i < nums.length; i++) {
                nums[i] = in.nextInt();
            }
            int target = in.nextInt();
            Solution solution = new Solution();
            System.out.println(Arrays.toString(solution.twoSum(nums, target)));
        }
    }
}